#ifndef __xwt_view_h
  #define __xwt_view_h

#include "xwt_window.h"

XWT_BEGIN_NAMESPACE(xwt);

/** A base genreic version of win32 view */
class View : public Window {
public:
	View ();	
	virtual ~View ();

	// operations...
public:
	virtual bool Create (int x, int y, int cx, int cy);
	virtual bool Create (const Rect &rect) {
		return Window::Create (rect, NULL);
	}

	// view management...
public:
	void AddSubView (View *subView);
	void RemoveSubView (View *subView);
	void RemoveAllSubViews ();
	void CenterView (Window *pParent);	
	void SetDoubleBuffered (bool flag = true);
	GC &GetCachedGC () {
		XWT_ASSERT(m_cached_gc);
		return *m_cached_gc;
	}

	// rendering...
public:	
	void RefreshView ();
	void RedrawView ();
	virtual void CalcLayout () { }

protected:
#ifdef WIN32
	virtual void GetCreateStyle (DWORD &dwStyle, DWORD &dwExStyle);
	virtual void GetClassStyle (WNDCLASSEX &wcex);
#endif

	// event handlers...
protected:
	XWT_DECL_EVENT_HANDLER(Create) ();
	XWT_DECL_EVENT_HANDLER(PreDestroy) ();
	XWT_DECL_EVENT_HANDLER(Resize) (int cx, int cy);

protected:
	// data members		
	GC *m_cached_gc;
	bool m_isDoubleBuffered;
	std::list<View *>m_subViews;
};

XWT_END_NAMESPACE(xwt);

#endif /* __xwt_view_h */
